package com.zg.datapush.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 数据推送配置属性
 * @author zg
 */
@Data
@Component
@ConfigurationProperties(prefix = "datapush")
public class DataPushProperties {

    /**
     * 调度配置
     */
    private Schedule schedule = new Schedule();

    /**
     * 日志配置
     */
    private Log log = new Log();

    /**
     * 重试配置
     */
    private Retry retry = new Retry();

    /**
     * 性能配置
     */
    private Performance performance = new Performance();

    /**
     * 安全配置
     */
    private Security security = new Security();

    @Data
    public static class Schedule {
        /**
         * 任务扫描间隔（毫秒）
         */
        private long scanInterval = 60000;

        /**
         * 任务执行超时时间（秒）
         */
        private int taskTimeout = 300;
    }

    @Data
    public static class Log {
        /**
         * 是否启用详细日志
         */
        private boolean detailEnabled = false;

        /**
         * 日志保留天数
         */
        private int retentionDays = 30;

        /**
         * 是否记录输入输出数据
         */
        private boolean recordData = true;
    }

    @Data
    public static class Retry {
        /**
         * 最大重试次数
         */
        private int maxAttempts = 3;

        /**
         * 重试间隔（毫秒）
         */
        private long backoffDelay = 1000;

        /**
         * 重试间隔倍数
         */
        private double backoffMultiplier = 2.0;
    }

    @Data
    public static class Performance {
        /**
         * 批量推送阈值
         */
        private int batchThreshold = 1000;

        /**
         * 单次推送最大数据量
         */
        private int maxBatchSize = 5000;

        /**
         * 是否启用缓存
         */
        private boolean cacheEnabled = true;

        /**
         * 缓存过期时间（秒）
         */
        private int cacheExpireSeconds = 300;
    }

    @Data
    public static class Security {
        /**
         * 是否启用数据脱敏
         */
        private boolean maskEnabled = true;

        /**
         * 敏感字段列表
         */
        private String[] sensitiveFields = {"password", "phone", "idCard", "bankCard"};

        /**
         * 是否启用SQL注入检查
         */
        private boolean sqlInjectionCheck = true;
    }
}
